; program to find the area of a rectangle
; author:  R. Detmer
; date:  revised 9/97

.386
.MODEL FLAT

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

INCLUDE io.h

cr          EQU    0dh   ; carriage return character
LF          EQU    0ah   ; linefeed character

.STACK  4096             ; reserve 4096-byte stack

.DATA                    ; reserve storage for data
prompt1     BYTE   "This program will find the area of a rectangle",cr,Lf,Lf
            BYTE   "Width of rectangle?  ",0
prompt2     BYTE   "Length of rectangle?  ",0
value       BYTE   16 DUP (?)
answer      BYTE   cr,Lf,"The area of the rectangle is "
area        BYTE   11 DUP (?)
            BYTE   cr,Lf,0

.CODE                               ; start of main program code
_start:
Prompt:     output prompt1          ; prompt for width
            input  value,16         ; read ASCII characters
            atod   value            ; convert to integer
            mov    ebx,eax          ; width

            output prompt2          ; prompt for length
            input  value,16         ; read ASCII characters
            atod   value            ; convert to integer
            mul    ebx              ; length * width
                         
            dtoa   area,eax         ; convert to ASCII characters
            output answer           ; output label and result

            INVOKE ExitProcess, 0   ; exit with return code 0
PUBLIC _start                       ; make entry point public
            END

